Skip to content

Disable wallet tools by default#267

Merged
codebycarson merged 4 commits into
mainfrom
feature/mcp-wallets
Jul 1, 2025
Merged

Disable wallet tools by default#267
codebycarson merged 4 commits into
mainfrom
feature/mcp-wallets

Conversation

@codebycarson

@codebycarson codebycarson commented Jul 1, 2025

Copy link
Copy Markdown
Collaborator

This PR adds a new way of adding wallet connection through a standardized interface as well as adds conditional availability of tools depending on if they have a wallet configured or not. It defaults to no wallet connection and thus no wallet based tools. Once the user changes the config they will get all the wallet based tools.

Follow up work will be done to add a couple wallet connection libraries to this.

This isn't released yet so if you want to test locally you need to replace the @sei-js/mcp-server with an absolute path to your local repo

Example (Read Only)

{
  "mcpServers": {
    "sei": {
      "command": "npx",
      "args": ["-y", "@sei-js/mcp-server"]
    }
  }
}

Example (Private Key Wallet Connection)

{
  "mcpServers": {
    "sei": {
      "command": "npx",
      "args": ["-y", "@sei-js/mcp-server"],
      "env": {
        "WALLET_MODE": "private-key",
        "PRIVATE_KEY": "0x123..."
      }
    }
  }
}

WALLET_API_KEY has been added for future use as a flag

This PR adds a new way of dealing with wallet connection and makes the wallet disabled by default. Users can pass in a private key explicitly to unlock all the wallet connection functionality.

- Added and adjusted tests
@changeset-bot

changeset-bot Bot commented Jul 1, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cd73506

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sei-js/mcp-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov-commenter

codecov-commenter commented Jul 1, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d3c5624) to head (cd73506).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #267   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           67        71    +4     
  Lines          763       827   +64     
  Branches       128       134    +6     
=========================================
+ Hits           763       827   +64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codebycarson
codebycarson requested a review from Copilot July 1, 2025 01:39
@codebycarson
codebycarson marked this pull request as ready for review July 1, 2025 01:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR “Disable wallet tools by default” introduces a new wallet configuration mechanism that conditionally registers wallet‐dependent tools only when a wallet is enabled, defaulting to disabled. Key changes include adding configuration functions (isWalletEnabled and getWalletMode), updating wallet provider usage throughout services and tools, and extensive updates to tests to reflect these modifications.

Reviewed Changes

Copilot reviewed 21 out of 24 changed files in this pull request and generated no comments.

File Description
packages/mcp-server/src/core/config.ts Introduces wallet configuration and new WALLET_API_KEY variable along with functions to check wallet mode.
packages/mcp-server/src/core/tools.ts Updates tool registration to separate read-only from wallet-dependent tools and refactors error messaging.
packages/mcp-server/src/core/wallet/* Updates wallet provider implementations and usage to align with new configuration and provider functions.
Various test files Refactor tests to use new wallet provider API (getWalletClientFromProvider, getAddressFromProvider) and validate error responses under disabled wallet mode.
Comments suppressed due to low confidence (2)

packages/mcp-server/src/core/config.ts:15

  • The WALLET_API_KEY environment variable is introduced but not yet used. Please consider documenting its intended future use or removing it if it is not needed at this stage.
	WALLET_API_KEY: z.string().optional() // Used for wallet providers

packages/mcp-server/src/core/tools.ts:1330

  • [nitpick] The error message for an unavailable wallet provider is hard-coded here. Consider centralizing and documenting standard error messages for wallet-related failures to improve consistency and ease of future updates.
							}

@codebycarson
codebycarson requested a review from dssei July 1, 2025 01:42

# Wallet Configuration
# Wallet mode: private-key | dynamic | porto | disabled
# - disabled: Disable all wallet functionality (default - safest for production)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, how will this work for dynamic and porto modes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It extends that same WalletProvider interface and adds a new wallet mode "dynamic"

# Wallet mode: private-key | dynamic | porto | disabled
# - disabled: Disable all wallet functionality (default - safest for production)
# - private-key: Use PRIVATE_KEY environment variable
WALLET_MODE=disabled

@dssei dssei Jul 1, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assume we are in readonly mode if no private key is set?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does default to disabled if no private key. We could make it not required for the wallet mode, but with dynamic added we will still need a wallet mode for that.

@codebycarson
codebycarson merged commit cab5074 into main Jul 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants